home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 23 / CU Amiga - Super CD-ROM 23 (June 1998).iso / CreatingGames / Utilities / Misc / GMS / GMSDev / Source / Asm / Chunky / ChunkySingle.s < prev    next >
Encoding:
Text File  |  1997-12-23  |  4.8 KB  |  204 lines

  1. ;-------T-------T------------------------T----------------------------------;
  2. ;Name:      Chunky Pixel List
  3. ;Author:    Paul Manias
  4. ;Copyright: DreamWorld Productions (c) 1996-1997.  Freely distributable.
  5. ;
  6. ;This demo is like the other pixel list demos but uses a CHUNKY8 screen type.
  7. ;Then screen size has been kept very small as the C2P routine is too slow,
  8. ;but this will be improved in the next version.  The good thing is that
  9. ;because the routine is transparent, using a graphics card would mean that
  10. ;this demo would run at the maximum possible speed (ie the chunky screen
  11. ;would be displayable, so no c2p would be needed).
  12. ;
  13. ;Press LMB to exit.
  14.  
  15.     INCDIR    "INCLUDES:"
  16.     INCLUDE    "dpkernel/dpkernel.i"
  17.  
  18.     SECTION    "Demo",CODE
  19.  
  20. ;===========================================================================;
  21. ;                             INITIALISE DEMO
  22. ;===========================================================================;
  23.  
  24.     STARTDPK
  25.  
  26. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  27.     move.l    DPKBase(pc),a6
  28.     lea    ScreenTags(pc),a0
  29.     sub.l    a1,a1
  30.     CALL    Init
  31.     tst.l    d0
  32.     beq.s    .Exit
  33.  
  34.     moveq    #ID_JOYDATA,d0    ;Get joydata structure.
  35.     CALL    Get
  36.     move.l    d0,JoyData
  37.     beq.s    .Exit
  38.     move.l    d0,a0    ;Initialise the joydata structure.
  39.     sub.l    a1,a1
  40.     CALL    Init
  41.     tst.l    .Exit
  42.  
  43.     move.l    Screen(pc),a0
  44.     CALL    Display
  45.  
  46.     bsr.s    Main
  47.  
  48. .Exit    move.l    DPKBase(pc),a6
  49.     move.l    JoyData(pc),a0
  50.     CALL    Free
  51.     move.l    Screen(pc),a0
  52.     CALL    Free
  53.     MOVEM.L    (SP)+,A0-A6/D1-D7
  54.     moveq    #ERR_OK,d0
  55.     rts
  56.  
  57. ;===========================================================================;
  58. ;                                MAIN LOOP
  59. ;===========================================================================;
  60.  
  61. Main:
  62. .loop    move.l    BLTBase(pc),a6
  63.     move.l    Screen(pc),a1
  64.     move.l    GS_Bitmap(a1),a0
  65.     CALL    bltClearBitmap
  66.  
  67.     lea    MList(pc),a2    ;a2 = Pointer to pixel list.
  68.     move.l    a2,a3    ;Drop the pixels here.
  69.     moveq    #31-1,d7
  70. .drop    addq.w    #1,2(a3)    ;a3 = YCoord+1
  71.     subq.l    #1,4(a3)    ;a3 = (Colour)-1
  72.     bge.s    .colok
  73.     clr.l    4(a3)
  74. .colok    addq.w    #8,a3
  75.     dbra    d7,.drop
  76.  
  77.     move.l    DPKBase(pc),a6
  78.     lea    MouseX(pc),a5
  79.     move.l    JoyData(pc),a0
  80.     CALL    Query
  81.  
  82.     move.l    JoyData(pc),a0
  83.     move.l    JD_Buttons(a0),d0
  84.     btst    #JB_LMB,d0
  85.     bne.s    .done
  86.  
  87.     move.w    JD_XChange(a0),d0
  88.     move.w    JD_YChange(a0),d1
  89.  
  90.     add.w    d1,2(a5)    ;d1 = (MouseY)+ChangeY
  91.     add.w    (a5),d0
  92.     move.l    Screen(pc),a0
  93. .ChkRX    cmp.w    GS_Width(a0),d0
  94.     blt.s    .ChkLX
  95.     move.w    GS_Width(a0),(a5)
  96.     bra.s    .Calculate
  97.  
  98. .ChkLX    tst.w    d0
  99.     bgt.s    .okX
  100.     clr.w    (a5)
  101.     bra.s    .Calculate
  102. .okX    move.w    d0,(a5)
  103.  
  104. .Calculate
  105.     move.l    (a5),-(sp)
  106.     moveq    #2,d1
  107.     CALL    FastRandom
  108.     subq.w    #1,d0
  109.     add.w    d0,(a5)
  110.  
  111.     moveq    #2,d1
  112.     CALL    FastRandom
  113.     subq.w    #1,d0
  114.     add.w    d0,2(a5)
  115.  
  116.     move.l    a2,a3
  117.     moveq    #31-1,d7
  118. .tloop    move.l    8(a3),(a3)
  119.     move.l    12(a3),4(a3)
  120.     addq.w    #8,a3
  121.     dbra    d7,.tloop
  122.  
  123.     move.l    BLTBase(pc),a6
  124.     move.l    Screen(pc),a0
  125.     move.l    GS_Bitmap(a0),a0
  126.     lea    PixelList(pc),a1    ;a1 = Pixel list.
  127.     CALL    bltDrawPixelList    ;>> = Draw pixels with clipping.
  128.     move.l    (sp)+,(a5)
  129.  
  130.     move.l    SCRBase(pc),a6
  131.     CALL    scrWaitAVBL
  132.     bra    .loop
  133. .done    rts
  134.  
  135. ;===========================================================================;
  136. ;                                  DATA
  137. ;===========================================================================;
  138.  
  139. JoyData:    dc.l  0
  140.  
  141. ScreenTags:    dc.l  TAGS_SCREEN
  142. Screen:        dc.l  0
  143.         dc.l  GSA_Width,256
  144.         dc.l  GSA_Height,128
  145.         dc.l  GSA_Palette,.palette
  146.         dc.l  GSA_Attrib,CENTRE
  147.         dc.l    GSA_BitmapTags,0
  148.         dc.l    BMA_Type,CHUNKY8
  149.         dc.l    TAGEND,0
  150.         dc.l  TAGEND
  151.  
  152. .palette    dc.l  PALETTE,32
  153.         dc.l  $000000,$101010,$171717,$202020,$272727,$303030
  154.         dc.l  $373737,$404040,$474747,$505050,$575757,$606060
  155.         dc.l  $676767,$707070,$777777,$808080,$878787,$909090
  156.         dc.l  $979797,$a0a0a0,$a7a7a7,$b0b0b0,$b7b7b7,$c0c0c0
  157.         dc.l  $c7c7c7,$d0d0d0,$d7d7d7,$e0e0e0,$e0e0e0,$f0f0f0
  158.         dc.l  $f7f7f7,$ffffff
  159.  
  160. PixelList:    dc.w   32,PXL_SIZEOF    ;Amount of entries, EntrySize.
  161.         dc.l   MList    ;Pointer to pixel list array.
  162. MList:        PIXEL  16,12,00    ;First pixel to draw (at back)
  163.         PIXEL  16,12,00    ;X/Y/Colour
  164.         PIXEL  16,12,00    ;..
  165.         PIXEL  16,12,00    ;..
  166.         PIXEL  16,12,00    ;..
  167.         PIXEL  16,12,00    ;..
  168.         PIXEL  16,12,00    ;..
  169.         PIXEL  16,12,00    ;..
  170.         PIXEL  16,12,00    ;..
  171.         PIXEL  16,12,00    ;..
  172.         PIXEL  16,12,00    ;..
  173.         PIXEL  16,12,00    ;..
  174.         PIXEL  16,12,00    ;..
  175.         PIXEL  16,12,00    ;..
  176.         PIXEL  16,12,00    ;..
  177.         PIXEL  16,12,00    ;..
  178.         PIXEL  16,12,00    ;..
  179.         PIXEL  16,12,00    ;..
  180.         PIXEL  16,12,00    ;..
  181.         PIXEL  16,12,00    ;..
  182.         PIXEL  16,12,00    ;..
  183.         PIXEL  16,12,00    ;..
  184.         PIXEL  16,12,00    ;..
  185.         PIXEL  16,12,00    ;..
  186.         PIXEL  16,12,00    ;..
  187.         PIXEL  16,12,00    ;..
  188.         PIXEL  16,12,00    ;..
  189.         PIXEL  16,12,00    ;..
  190.         PIXEL  16,12,00    ;..
  191.         PIXEL  16,12,00    ;..
  192.         PIXEL  16,12,00    ;..
  193. MouseX:        PIXEL  16,12,31    ;Last pixel to draw (in front)
  194.  
  195. ;===========================================================================;
  196.  
  197. ProgName:    dc.b  "Chunky Pixels",0
  198. ProgAuthor:    dc.b  "Paul Manias",0
  199. ProgDate:    dc.b  "December 1997",0
  200. ProgCopyright:    dc.b  "DreamWorld Productions (c) 1996-1997.  Freely distributable.",0
  201. ProgShort:    dc.b  "Chunky demo, single buffer.",0
  202.         even
  203.  
  204.